﻿CREATE PROCEDURE [dbo].[proc_Order_Change_GetItem]
	(
		@Id int,
		@OId uniqueidentifier
	)
AS
	Select
		Id
		,OId
		,IsNull(OrderId,'') As OrderId
		,CusId
		,CusName
		,TypeId
		,Salesman
		,SalesmanAccount
		,TradeDate
		,CreateDate
		,IsNull(ShiShouPrice,0) As ShiShouPrice
		,(Select oldje From Order_Change Where Id=@Id And OId=@OId) As YingShouPrice	--变更前的成单金额
		,Convert(varchar(20),(Select newje From Order_Change Where Id=@Id And OId=@OId)) As htbh	--使用htbh这个字段代替变更后的成单金额
		,IsNull((Select bgnr From Order_Change Where Id=@Id And OId=@OId),'') As CusDescription	--变更内容
		,(Select shqr From Order_Change Where Id=@Id And OId=@OId) As shjbh	--申请人编号
		,(Select shqrxm From Order_Change Where Id=@Id And OId=@OId) As AuditPerson	--申请人姓名
		,(Select shqrq From Order_Change Where Id=@Id And OId=@OId) As AuditDate	--申请日期
		,(Select ChangeType From Order_Change Where Id=@Id And OId=@OId) As ChangeType	--变更类型
		,Convert(int,(Select flag From Order_Change Where Id=@Id And OId=@OId)) As flag	--变更状态
	From [Order] Where OId=@OId
	RETURN